package com.itheima.Service.Servicelmpl;

import com.itheima.Service.SetmealService;
import com.itheima.mapper.SetmealMapperl;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Setmeal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SermealServicelpml implements SetmealService {
    @Autowired
    private SetmealMapperl setmealMapperl;
    /**
     * 用户端查询所有套餐
     * @return
     */
    public List<Setmeal> llistsetmeal() {
        return setmealMapperl.list();
    }

    /**
     * 查询套餐详细信息
     * @param id
     * @return
     */
    public Setmeal list(Integer id) {
        //根据套餐id查询关联的检查组
        Setmeal setmeal = setmealMapperl.list1(id);
        List<CheckGroup> ARR = setmealMapperl.list3(id);
        for (CheckGroup checkGroup : ARR) {
            Integer id1 = checkGroup.getId();
            List<CheckItem> checkItems = setmealMapperl.list2(id1);
            checkGroup.setCheckItems(checkItems);
        }
        setmeal.setCheckGroups(ARR);
        return setmeal;
    }
}
